package mirkofrancuski.battleship;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.Window;
import android.view.WindowManager;

public class MenuActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);			
		
		
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.menu, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case R.id.menu_help:
			showHelp();
			break;
		case R.id.menu_share:
			share();
			break;
		case R.id.menu_about:
			showAbout();
			break;
		default:
			return super.onOptionsItemSelected(item);
		}
		return true;
	}

	private void showHelp() {
		startActivity(new Intent(this, HelpActivity.class));
	};

	private void share() {
		Intent sendIntent = new Intent();
		sendIntent.setAction(Intent.ACTION_SEND);
		sendIntent.putExtra(Intent.EXTRA_TEXT,
				getResources().getString(R.string.share_text));
		sendIntent.setType("text/plain");
		startActivity(Intent.createChooser(sendIntent, getResources()
				.getString(R.string.share_title)));
	};

	private void showAbout() {
		startActivity(new Intent(this, AboutActivity.class));
	}

}
